<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_header :: common_header(~{::title},~{::link},~{})">
    <title>新增设备 - 设备管理</title>


</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-device-add">
        <input type="hidden" id="programId" name="programId" th:value="${programId}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>项目名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" style="width: 100%;" th:value="${programName}">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>设备类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
					<span class="select-box" style="width: 150px"> <select
                            class="select" name="deviceType" id="deviceType">
							<option value="">请选择设备类型</option>
							<option th:each="dt:${deviceTypes}"
                                    th:value="${dt.key}" th:text="${dt.value}"></option>
					</select>
					</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>黑匣子编码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" style="width: 100%;" value=""
                       placeholder="" id="serialNo" name="serialNo">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>设备备案号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" style="width: 100%;" value=""
                       placeholder="" id="registNo" name="registNo">
            </div>
        </div>

        <input id="content" name="content" type="hidden">

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button class="btn btn-primary radius" type="submit">
                    <i class="Hui-iconfont">&#xe632;</i> 保存
                </button>
            </div>
        </div>
    </form>
</article>

<div th:replace="_footer :: foot"></div>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $(".textarea").Huitextarealength({
            minlength: 0,
            maxlength: 2000,
            exceed: false
        });
        //表单验证
        $("#form-device-add").validate({
            rules: {
                deviceName: {
                    required: true,
                },
                deviceKey: {
                    required: true,
                },
                deviceSecret: {
                    required: true,
                }
            },
            onkeyup: false,
            focusCleanup: false,
            success: "valid",
            submitHandler: function (form) {
                ajaxSubmit();
            }
        });

        function ajaxSubmit() {
            $.ajax({
                asyns: false,
                cache: false,
                type: 'POST',
                data: $('#form-device-add').serialize(),
                url: "insert",
                success: function (data) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            });
            return false;
        };
    });
</script>

</body>
</html>